package com.xian;

import java.util.Scanner;

/**
 * @Author: yanjunfeng
 * @Description: TODO
 * @Date: Created in 下午3:07 2022/7/13
 * @Modified By:
 */
public class EmployeeTest {
    public static void main(String[] args) {
        Employee[] employees=new Employee[10];//创建一个数组，保存10个员工的数据

        Scanner sc=new Scanner(System.in);
       for(int i=0;i<employees.length;i++){
           System.out.println("请输入员工类型0-固定工资  1-时薪  2-无固定底薪 3-有固定底薪");
           int type=sc.nextInt();
           if(type==0){
               System.out.println("请输入员工姓名");
               String name=sc.next();
               System.out.println("请输入员工出生月份");
               int month=sc.nextInt();
               System.out.println("请输入员工月薪");
               double monthSalary= sc.nextDouble();
               Employee employee=new SalariedEmployee(name,month,monthSalary);//向上转型
               employees[i]=employee;
           }else if(type==1){
               System.out.println("请输入员工姓名");
               String name=sc.next();
               System.out.println("请输入员工出生月份");
               int month=sc.nextInt();
               System.out.println("请输入员工的时薪");
               double hourlyWage=sc.nextDouble();
               System.out.println("请输入员工的月工作时长");
               int hour=sc.nextInt();
               Employee employee=new HourlyEmployee(name,month,hour,hourlyWage);//多态向上转型m
               employees[i]=employee;

           }else if(type==2){
               System.out.println("请输入员工姓名");
               String name=sc.next();
               System.out.println("请输入员工出生月份");
               int month=sc.nextInt();
               System.out.println("请输入员工的销售额");
               int salesVolume=sc.nextInt();
               Employee employee=new SalesEmployee(name,month,salesVolume);
               employees[i]=employee;

           }else if(type==3){
               System.out.println("请输入员工姓名");
               String name=sc.next();
               System.out.println("请输入员工出生月份");
               int month=sc.nextInt();
               System.out.println("请输入员工的销售额");
               int salesVolume=sc.nextInt();
               System.out.println("请输入员工底薪");
               double baseSalary=sc.nextDouble();
               Employee employee=new BasePlusSalesEmployee(name,month,salesVolume,baseSalary);
               employees[i]=employee;

           }else{
               System.out.println("用户输入错误");
               break;
           }
       }
       for(int i=0;i<employees.length;i++){
           System.out.println("员工姓名:"+employees[i].getName()+"  工资:"+employees[i].getSalary());
       }
//       160*30+（190-160）*30*1.5+100
//                =4800+1350+100
       // 30000*0.05=1500 150000*0.08=12000
    }
}
